<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2025/4/10
  Time: 14:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<%request.setCharacterEncoding("utf-8");%>
<% String StuNo= request.getParameter("stuid");%>
<% String StuTelephone= request.getParameter("stutelephone");%>
<% String StuEmail= request.getParameter("stuemail");%>
<% String stuPolitcalStatus= request.getParameter("stupolitcalstatus");%>
<% String StuSpeciality= request.getParameter("Stuspeciality");%>
<html>
<head>
    <title>修改结果</title>
        <%!  ResultSet rs;%>
<%
        String dbName = "student";
        String userName = "root";
        String userPasswd = "123456";
        String url ="jdbc:mysql://172.21.32.100/" + dbName + "?user=" + userName + "&password=" + userPasswd+"&useUnicode=true&characterEncoding=utf-8";
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url);
        String sql = "update student set stu_politcalstatus=?,stu_telephone=?,stu_email=?,stu_speciality=?,stu_stupolitcalstatus=?, where stu-no=?";
      PreparedStatement preparedStatement= conn.prepareStatement(sql);
      PreparedStatement.setString(1,stuPolitcalStatus);
      PreparedStatement.setString(2,StuSpeciality);
      PreparedStatement.setString(3,StuTelephone);
      PreparedStatement.setString(4,StuEmail);
      PreparedStatement.setString(5,StuNo);


      int result= preparedStatement.executeUpdate();
      if(result>0)
          out.print(" <script type='text/javascript'>alert('修改成功');</script>");
      else
          out.print(" <script type='text/javascript'>alert('修改失败');</script>");
    sql = "select * from student ";
    preparedStatement= conn.prepareStatement(sql);
    rs = preparedStatement.executeQuery(sql);
        %>
</head>
<body>
<table border="1">
    <th colspan="7" style="font-size:x-large;alignment:center" >学生信息表</th>
    <tr style="text-align: center">
        <td>学号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>政治身份</td>
        <td>出生日期</td>
        <td>身份证号</td>
        <td>所在系部</td>
    </tr>
        <%while (rs.next()){ %>
    <tr style="...">
        <td><%= rs.getString(1)  %></td>
        <td><%= rs.getString(2)  %></td>
        <td><%= rs.getString(3)  %></td>
        <td><%= rs.getString("stu_politicalstatus")  %></td>
        <td><%= rs.getString("stu_birthday")  %></td>
        <td><%= rs.getString("stu_identitycard")  %></td>
        <td><%= rs.getString("stu_speciality")  %></td>
    </tr>
        <% } %>
        <%
    rs.close();
    preparedStatement.close();
    conn.close();
%>
</body>
</html>
